package practice;

import java.util.function.Predicate;

public class Team {
	private String a;
	private String b;
	private String c;
	Predicate<Team> pre;
	
	public Team(String a, String b, String c) {
		this.a = a;
		this.b = b;
		this.c = c;
	}
	
	public void setPredicate(Predicate<Team> pre) {
		this.pre = pre;
	}
	
	public boolean match() {
		return pre.test(this);
	}
	
	public String toString() {
		return "a的对手是" + a + "，b的对手是" + b + "，c的对手是" + c;
	}

	public static void main(String[] args) {
		String[] t = {"x", "y", "z"};
		for (int i = 0; i < 3; i++)
			for (int j = 0; j < 3; j++) {
				if (j == i)
					continue;
				for (int k = 0; k < 3; k++) {
					if (k == i || k == j)
						continue;
					Team abc = new Team(t[i], t[j], t[k]);
					abc.setPredicate(team -> !team.a.equals("x") && 
							!team.c.equals("x") && !team.c.equals("z"));
					if (abc.match())
						System.out.println(abc);
				}
			}
	}
}
